{% load nm %}
{% if progs %}
<table class="proctable tablesorter">
    <thead>
        <tr>
            <th>Started</th>
            <th>Last</th>
            <th>Target</th>
            <th>Applicant</th>
            <th>Uid</th>
            <th>Adv.</th>
            {% if "m" in extras %}
            <th>Manager</th>
            {% endif %}
            <th>Last log</th>
        </tr>
    </thead>
    <tbody>
    {% for p in progs %}
    <tr>
        <td>{{p.started|date:"Y-m-d"}}</td>
        <td>{{p.last_change|date:"Y-m-d"}}</td>
        <td>{{p.applying_for|sdesc_status}}</td>
        <td><a href="{{ p.get_absolute_url }}">{{p.person}}</a></td>
        <td><a href="{{ p.get_absolute_url }}">{{p.person.uid}}</a></td>
	<td>
	    {% for a in p.advocates.all %}
	    <a href="{{ a.get_absolute_url }}">{{a.uid}}</a>
	    {% endfor %}
	</td>
	{% if "m" in extras %}
        <td><a href="{{ p.manager.get_absolute_url }}">{{p.manager.person.uid}}</a></td>
    {% endif %}
    <td>
        {% if p.log_last.logtext %}
        {{ p.log_last.logtext }}
        {% else %}
        [{{p.log_last.progress|sdesc_progress}}]
        {% endif %}
    </td>
    </tr>
    {% endfor %}
    </tbody>
</table>
{% else %}
<p><i>none</i></p>
{% endif %}

